import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;

public class SocketServer {
    public static void main(String[] args) throws IOException {

        ServerSocket serverSocket = null;
        Socket accept = null;

        try {
            serverSocket = new ServerSocket(8090);
            while (true){
                accept = serverSocket.accept();
                InetAddress inetAddress = accept.getInetAddress();
                System.out.println(inetAddress);

                OutputStream outputStream = accept.getOutputStream();
                PrintWriter printWriter = new PrintWriter(outputStream);
                printWriter.write("server welcome："+inetAddress);
                printWriter.flush();
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
